﻿Type=Activity
Version=6
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Private lvsearchresultteacher As clsCustomListView
	Private itemstartprice As Label
	Private itemteacheage As Label
	Private itemteacheradwords As Label
	Private itemteacherdistence As Label
	Private itemteachernickname As Label
	Private itemteaheadimg As ImageView
	Private lst As List
	Private itemrate As Label
	Private itemsex As ImageView
	Private lblsearchkeywords As Label
	Private btnleft As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim telaw As telanywhere
telaw.Initialize(Activity)

	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("laysearchteacherresult")
	initviews
End Sub
Sub initviews
	Dim nH As Int=120dip
	comm.setFA(btnleft,"fa-angle-left","")
	lst=g_store.conf.Get("searchtec")
	lblsearchkeywords.Text="搜索结果:"&g_store.conf.GetDefault("searchkeyword","")
	If lst.IsInitialized And lst.Size>0 Then
		For i=0 To lst.Size-1
			lvsearchresultteacher.Add(CreateItemTeacher(100%x,nH,i),nH,i)
		Next
	Else
'		Msgbox("没有搜索结果","错误")
'		Activity.Finish
		lvsearchresultteacher.Add(CreateItemEmpty(100%x,nH),nH,0)
	End If
	
End Sub
Private Sub CreateItemEmpty(w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemempty")
	p.RemoveView
	Return p
End Sub
Private Sub CreateItemTeacher(w As Int,h As Int,i As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemteacher")
	Dim t As Teacher=lst.Get(i)
	itemstartprice.Text="￥"&t.startPrice
	itemteacheage.Text=t.teacheAge&"年"
	itemteacheradwords.Text=t.adWords
	'itemteacherdistence.Text=t.distence
	itemteachernickname.Text=t.nickname
	comm.setViewWrapContent(itemteachernickname)
	comm.loadimground(t.headimg,itemteaheadimg,0,0)
	itemrate.Text="评论数:"&t.rateNum&"条 好评率:"&t.ratePercent&" 学生数:"&t.stunum
	If t.sexMen Then
		itemsex.Bitmap=comm.bmpSexMan
		comm.setivsexsize(itemsex,True)
	Else
		itemsex.Bitmap=comm.bmpSexWoman
		comm.setivsexsize(itemsex,False)
	End If
	itemsex.Left=itemteachernickname.Left+itemteachernickname.Width+5dip
	itemteacheage.Left=itemsex.Left+itemsex.Width+5dip
	comm.setFA(itemteacherdistence,"fa-map-marker"," "&t.distence)
	p.RemoveView
	Return p
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub lvsearchresultteacher_ItemClick (Index As Int, Value As Object)
	Dim t As Teacher=lst.Get(Index)
	g_store.put("tecid",t.ID)
	StartActivity(actTeacherDetail)
End Sub

Sub ivback_Click
	Activity.Finish
End Sub